import {
  Controller,
  Get,
  Post,
  Body,
  Param,
  Delete,
  Request,
  Query,
  Put,
} from '@nestjs/common';
import { InRecordService } from './in-record.service';

@Controller('inRecord')
export class InRecordController {
  constructor(private readonly inRecordService: InRecordService) {}

  @Post()
  create(@Body() createData, @Request() req) {
    createData.creator = req.user.id;
    return this.inRecordService.create(createData);
  }

  @Post('list')
  findAll(@Body() createData) {
    return this.inRecordService.findAll({ ...createData });
  }

  @Get(':id')
  findOne(@Param('id') id: number) {
    return this.inRecordService.findOne({ id });
  }

  @Put()
  update(@Body() updateData) {
    console.log(updateData,'updateData')
    let { id,remark,type,supplierId,InGoods } = updateData
    return this.inRecordService.update({
      where: { id: +id },
      data: {
        remark,
        type,
        supplierId,
        InGoods,
      },
    });
  }

  @Delete()
  remove(@Query('id') id: number) {
    return this.inRecordService.delete({ id 
    });
  }
}
